#include<iostream>
#include<cstring>
using namespace std;
int block1[7][7],ans[7][7],block2[7][7];
int minSteps=1<<30;
int Count(){
    int count=0;
    for(int i=1;i<=4;i++){        
        for(int j=1;j<=4;j++){
            if(ans[i][j]){
                count++;
            }
        }
    }
    return count;
}
bool check(){
    //black to white
    for(int i=2;i<=5;i++){
        for(int j=1;j<=4;j++){
            ans[i][j]=block1[i-1][j]^ans[i-1][j]^ans[i-1][j-1]^ans[i-1][j+1]^ans[i-2][j];
        }
    }
    if(!ans[5][1]&&!ans[5][2]&&!ans[5][3]&&!ans[5][4]){
        return true;
    }
    //white to black
    for(int i=2;i<=5;i++){
        for(int j=1;j<=4;j++){
            ans[i][j]=block2[i-1][j]^ans[i-1][j]^ans[i-1][j-1]^ans[i-1][j+1]^ans[i-2][j];
        }
    }
    if(!ans[5][1]&&!ans[5][2]&&!ans[5][3]&&!ans[5][4]){
        return true;
    }
    return false;
}
int main(){
    for(int i=1;i<=4;i++)
        for(int j=1;j<=4;j++){
            char ch;
            cin>>ch;
            block1[i][j]=int(ch=='b');
            block2[i][j]=int(ch=='w');
        }         
    for(int i=0;i<(1<<4);i++){
        int temp=i;
        for(int j=1;j<=4;j++){
            ans[1][j]=temp%2;
            temp/=2;
        }
        if(check()){
            minSteps=min(minSteps,Count());
        }
    }
    if(minSteps==(1<<30)){
        cout<<"Impossible"<<endl;
    }else{
        cout<<minSteps<<endl;
    }    
    return 0;
}